package com.ruoyi.generator.controller;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.generator.entity.CheckPlan;
import com.ruoyi.generator.entity.PlanAssociation;
import com.ruoyi.generator.entity.bo.PlanAssociationBO;
import com.ruoyi.generator.entity.bo.PlanScheduleBO;
import com.ruoyi.generator.service.CheckPlanService;
import org.aspectj.weaver.loadtime.Aj;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.time.LocalTime;
import java.time.format.DateTimeFormatter;
import java.util.List;

/**
 * 点检计划
 */
@RestController
@RequestMapping("/checkplan")
public class CheckPlanController extends BaseController {

    @Autowired
    private CheckPlanService checkPlanService;

    /**
     * 获取点检计划列表
     *
     * 暂时没用
     * @return
     */
    @GetMapping("/list")
    public TableDataInfo list(CheckPlan checkPlan){
        startPage();
        List<CheckPlan> list = checkPlanService.getCheckPlanList(checkPlan);
        return getDataTable(list);
    }


    /**
     * 获取设备所有信息
     *
     * 暂时没用
     * @return
     */
    @GetMapping("/info")
    public AjaxResult getPlanAssociationInfo(){
        List<PlanAssociationBO> list = checkPlanService.getPlanAssociationInfo();
        return AjaxResult.success(list);
    }


    /**
     * 获取设备所有列表
     *
     * @param planAssociation
     * @return
     */
    @GetMapping("/plan/list")
    public TableDataInfo getPlanAssociationList(PlanAssociation planAssociation){
        startPage();
        List<PlanAssociationBO> list = checkPlanService.getPlanAssociationList(planAssociation);
        return getDataTable(list);
    }

    /**
     * 新增点检周期
     * @param planScheduleBO
     * @return
     */
    @PostMapping("/plan/schedule")
    public AjaxResult addPlanAssociation(@RequestBody PlanScheduleBO planScheduleBO){
        int rows = checkPlanService.addPlanAssociation(planScheduleBO);
        if (rows != 0){
            return AjaxResult.success();
        }
        return AjaxResult.error();
    }




}
